package com.boot.unity.api.modules.train.service.impl;

import com.boot.unity.api.modules.train.dto.PhysicalExaminationDTO;
import com.boot.unity.api.modules.train.result.Result;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.boot.unity.api.modules.train.service.PhysicalExaminationService;
import com.boot.unity.api.modules.train.dao.PhysicalExaminationDao;
import com.boot.unity.api.modules.train.entity.PhysicalExamination;
/**
 * @author anonymous
 *
 * @create 2020-09-08 16:10:52
 */
@Slf4j
@Service
@AllArgsConstructor
public class PhysicalExaminationServiceImpl implements PhysicalExaminationService {

    private final PhysicalExaminationDao physicalExaminationDao;

    @Override
    public Result save(PhysicalExaminationDTO physicalExaminationDTO) {
        try {
            PhysicalExamination examination = new PhysicalExamination();
            BeanUtils.copyProperties(physicalExaminationDTO, examination);
            physicalExaminationDao.save(examination);
            return Result.success("保存体检结果成功");
        }catch (Exception e){
            e.printStackTrace();
            log.error("保存体检结果失败[{}]",e.getMessage());
        }
        return Result.fail("保存体检结果失败");
    }
}
